package com.liangzhong.modules.friend.command
{
	import com.liangzhong.constants.ApplicationConstants;
	import com.liangzhong.proxy.friend.FriendProxy;
	import com.liangzhong.proxyconstant.friend.FriendProxyConstant;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	/**
	 *好友 
	 * @author Administrator
	 * 
	 */	
	public class FriendCommand extends SimpleCommand
	{
		public function FriendCommand()
		{
			super();
		}
		override public function execute(notification:INotification):void
		{
			var proxy:FriendProxy
			switch(notification.getName())
			{
				case FriendProxyConstant.FRIEND_MEDIATOR_PROXY://mediator处理
					mediatorNotification(notification);
					break;
				case ApplicationConstants.FRIEND_GETFRIENDCLUBINFO://获取他人信息
					proxy = facade.retrieveProxy(FriendProxy.ProxyName) as FriendProxy;
					proxy.getFriendClubInfo(notification.getBody());
					break;
				case ApplicationConstants.FRIEND_CHALLENGE://发起挑战 
					proxy = facade.retrieveProxy(FriendProxy.ProxyName) as FriendProxy;
					proxy.requestFriendChanglle(notification.getBody());
					break;
				case ApplicationConstants.FRIEND_INVITEFRIENDS://邀请好友
					proxy = facade.retrieveProxy(FriendProxy.ProxyName) as FriendProxy;
					proxy.requestInvite_By_ID(notification.getBody());
					break;
				case ApplicationConstants.FRIEND_CANCEL_CHALLENGE:
					proxy = facade.retrieveProxy(FriendProxy.ProxyName) as FriendProxy;
					proxy.requesetCanelFight(notification.getBody());
					break;
			}
		}
		/**
		 * clubMediator -->clubCommand 通知
		 * @param notification
		 * 
		 */		
		private function mediatorNotification(notification:INotification):void
		{
			var proxy:FriendProxy = facade.retrieveProxy(FriendProxy.ProxyName) as FriendProxy;
			switch(notification.getType())
			{
				case FriendProxyConstant.NAME_INVITE://mediator处理
					proxy.requestNameInvite(notification.getBody());
					break;
				case FriendProxyConstant.FRIEND_INFO://请求好友信息
					proxy.getFriendList();
					break;
				case FriendProxyConstant.ONLINE_FRIEND://在线好友
					proxy.requestOnlineFriend();
					break;
				case FriendProxyConstant.AGREE_FRIEND_INVITE://同意好友的邀请
					proxy.requestAgreeInvite(notification.getBody());
					break;
				case FriendProxyConstant.REFUSE_FRIEND_INVITE://拒绝好友的邀请
					proxy.requestrefuseInvite(notification.getBody());
					break;
//				case FriendProxyConstant.INVITE_BY_ID://
//					proxy.requestInvite_By_ID(notification.getBody());
//					break;
				case FriendProxyConstant.RECOMMEND_FRIEND:
					proxy.requestRecommendList(notification.getBody());
					break;
				case FriendProxyConstant.RECEIVE_INVITE://接受到好友的邀请列表
					proxy.requestReceiveInviteList();
					break;
				case FriendProxyConstant.DELETE_FRIEND:
					proxy.requestDeleteFriend(notification.getBody());
					break;
			}
		}
	}
}